home *** CD-ROM | disk | FTP | other *** search
Wrap
/********************************************************** * * * (C) Copyright 2002 - 2004, Human Concepts (tm) * * * *********************************************************** * File name: toolbarFunc.js * * Author: Andrey Ponomarev * **********************************************************/ var zoomValue = 1.0; var bZoomOnWheel = false; var oOverwiewWnd; var bZoomInitReady = false; var AdditionalButtons = ( parent.isEnableSave() ? 1 : 0 ) + ( parent.isEnablePrint() ? 1 : 0 ); if( AdditionalButtons > 0 ) AdditionalButtons++; // separator var nSaveButtonNumber = ( parent.isEnableSave() ? 1 : 0 ); var zoomInButton = 0 + AdditionalButtons; var nZoomCombo = 2 + AdditionalButtons; var nZoomFitButtonNumber = 3 + AdditionalButtons; var nZoomWheelButtonNumber = 4 + AdditionalButtons; window.onunload = doUnload; var strZoomSupportMsg = "To fully support OrgPlus HTML Zoom functionality,\n\ryou will need to upgrade your Internet Explorer to\n\rat least version 5.5" //Loc function doUnload() { if ( typeof(oOverwiewWnd) == "object" && !oOverwiewWnd.closed) { oOverwiewWnd.close() } } function buttonIn_onclick() { ClearAutoFitFlag() DoZoomIn() } function ClearAutoFitFlag() { if (getIEVersion() >= 5.5 && typeof(oToolBar) != 'undefined') oToolBar.getItem(nZoomFitButtonNumber).setAttribute('selected', 'false') } function SetAutoFitFlag() { if (getIEVersion() >= 5.5 && typeof(oToolBar) != 'undefined') oToolBar.getItem(nZoomFitButtonNumber).setAttribute('selected', 'true') } function buttonOut_onclick() { ClearAutoFitFlag() DoZoomOut() } function onclick_Save() { window.open( GetOpxPath(), "_blank", "status=no,toolbar=no,menubar=no,location=no" ); } function GetOpxPath() { return parent.GetOpxPath(); } function setZoomExt(zoomVal) { if( getIEVersion() < 5.5 ) { alert(strZoomSupportMsg ); return; } if( zoomVal > 0) { switchScrolling(true); setZoom(zoomVal); } else ZoomToFit(); } function buttonZoomToFit_onclick() { if (getIEVersion() < 5.5) { alert(strZoomSupportMsg); return; } ZoomToFit(); tryCenterPage(); } function ZoomToFitInit() { if (getIEVersion() < 5.5) { tryCenterPage() updateOverviewWindow() } else { if (!bZoomInitReady) { DoZoomToFitInit() bZoomInitReady = true } else { ClearAutoFitFlag() setZoom(zoomValue) } } } function HitTestReaction() { //alert('hit test')//onClickGroup() } function UpdateHitTestRectsByZoom() { if (!isSelectionEnabled()) return var st_strRectForHitTestName = "_HitTestRect" var groupObjs = parent.hcMain.PageGroup.document.getElementsByTagName("group") var zoomValue = parseFloat(parent.hcMain.PageGroup.style.zoom) if (zoomValue == 0.0) zoomValue = 0.01 for (i = 0; i < groupObjs.length; i++) { var objGroup = groupObjs[i] if (objGroup.id == "PageGroup") continue var strName = objGroup.id + st_strRectForHitTestName var bFound = false var elem for (j = 0; j < objGroup.children.length; j++) { if (objGroup.children[j].id == strName) { elem = objGroup.children[j] bFound = true break } } if (!bFound)//if not found - create { elem = objGroup.document.createElement("v:rect") elem.id = strName elem.style.top = 0 elem.style.left = 0 elem.setAttribute("stroked", "false") //elem.setAttribute("filled", "false") //elem.onclick = HitTestReaction var fill = objGroup.document.createElement("v:fill") fill.setAttribute("color", "#009000") fill.setAttribute("opacity", ".0") objGroup.appendChild(elem) elem.appendChild(fill); } if (typeof(elem) == "object") { var k = 1. / zoomValue; var m = objGroup.style.pixelWidth if (k > 1) m = m * k else m = 0 elem.style.width = m m = objGroup.style.pixelHeight if (k > 1) m = m * k else m = 0 elem.style.height = m } } } function onZoomCombo() { ClearAutoFitFlag() var obj = event.srcElement setZoomExt(obj.value) parent.hcMain.focus() } function buttonPrint_onclick() { window.open( parent.hcMain.location.href, "_blank", "_blank","height=200,width=760px,status=no,toolbar=no,menubar=yes,location=no"); } function buttonOverview_onclick() { if ( typeof(oOverwiewWnd) == "undefined" || typeof(oOverwiewWnd) == "object" && oOverwiewWnd.closed ) { var objMain = parent.hcMain if ( typeof(objMain) != "object" || typeof(objMain.PageGroup) != "object" ) { //onOverviewClosed() alert("Sorry, can't display Overview Window - Chart document is not loaded yet") //Loc return } oOverwiewWnd = window.showModelessDialog("overviewWnd.html", window, "dialogHide=yes; center=no; help=no; dialogLeft=500; dialogTop=30; status=no; dialogHeight:10; dialogWidth:14; resizable:no; scroll:no; edge:sunken"); } else { oOverwiewWnd.close() } } function onOverviewWndCreated() { initOverviewWindow() updateOverviewWindow() } function updateOverviewWindow() { if ( typeof(oOverwiewWnd) == "object" && !oOverwiewWnd.closed) { oOverwiewWnd.draw(parent.hcMain) } } function initOverviewWindow() { if ( typeof(oOverwiewWnd) == "object" && !oOverwiewWnd.closed) { var objMain = parent.hcMain if (typeof(objMain) == "object") { var objPageGroup = objMain.document.getElementById("PageGroup") if (typeof(objPageGroup) == "object") { var strImg = objMain.strImageForPreview if ( typeof(strImg) == 'undefined' ) strImg = "" oOverwiewWnd.initPage( objPageGroup, strImg ) } } } } function buttonShowHidePanels_onclick() { if (parent.isShowPanelsEnable()) { parent.bHidePanelsByDefault = !parent.bHidePanelsByDefault; parent.DoHideShowPanels(); } } function buttonZoomOnWheel_onclick() { bZoomOnWheel = !bZoomOnWheel var ver = getIEVersion() if (bZoomOnWheel && ver < 6.0) alert("You should Update Internet Explorer to Version 6.0 or higher\r\nto have Zoom on Mouse Wheel") //Loc } function onChartMouseWheeling(evnt) { if (bZoomOnWheel) { if (evnt.wheelDelta >= 120) { buttonIn_onclick() } else if (evnt.wheelDelta <= -120) { buttonOut_onclick() } } } function HumanConcepts_onclick() { parent.location = "http://www.humanconcepts.com" } function isSelectionEnabled() { return (parent.bIndexPage || parent.bCountPage || parent.bProfilePage) } function tryCenterPage() { var obj = parent.hcMain.document.body; //.all.PageGroup; var wndHeight = parseInt(obj.clientHeight); var wndWidth = parseInt(obj.clientWidth); var oPage = parent.hcMain.PageGroup; if (typeof(oPage) != "object") return; oPage.style.visibility = 'hidden'; var nZoomValue = 1. if (getIEVersion() >= 5.5) nZoomValue = zoomValue var pageHeight = oPage.style.pixelHeight * nZoomValue var pageWidth = oPage.style.pixelWidth * nZoomValue var nLeft = 0 if (wndWidth > pageWidth) nLeft = (wndWidth - pageWidth) / 2 var nTop = 0 if (wndHeight > pageHeight) nTop = (wndHeight - pageHeight) / 2 oPage.style.left = parseInt(nLeft) oPage.style.top = parseInt(nTop) oPage.style.visibility = 'visible' } function DoZoomIn() { if (zoomValue < 3) { if (zoomValue < 0.25) zoomValue = 0.25; else if (zoomValue < 0.5) zoomValue = 0.5; else if (zoomValue < 0.75) zoomValue = 0.75; else if (zoomValue < 1.0) zoomValue = 1.0; else if (zoomValue < 1.25) zoomValue = 1.25; else if (zoomValue < 1.5) zoomValue = 1.5; else if (zoomValue < 1.75) zoomValue = 1.75; else if (zoomValue < 2.0) zoomValue = 2.0; else if (zoomValue < 2.25) zoomValue = 2.25; else if (zoomValue < 2.5) zoomValue = 2.5; else if (zoomValue < 2.75) zoomValue = 2.75; else if (zoomValue < 3.0) zoomValue = 3.0; setZoomExt(zoomValue); } } function DoZoomOut() { if (zoomValue > 0.25) { if (zoomValue > 3.0) zoomValue = 3.0; else if (zoomValue > 2.75) zoomValue = 2.75; else if (zoomValue > 2.5) zoomValue = 2.5; else if (zoomValue > 2.25) zoomValue = 2.25; else if (zoomValue > 2.0) zoomValue = 2.0; else if (zoomValue > 1.75) zoomValue = 1.75; else if (zoomValue > 1.5) zoomValue = 1.5; else if (zoomValue > 1.25) zoomValue = 1.25; else if (zoomValue > 1.0) zoomValue = 1.0; else if (zoomValue > 0.75) zoomValue = 0.75; else if (zoomValue > 0.5) zoomValue = 0.5; else if (zoomValue > 0.25) zoomValue = 0.25; setZoomExt(zoomValue); } } function setZoom(value) { zoomValue = parseFloat(value) //var tmpInt = parseInt( (parseFloat(value) + 0.01) * 10) //to avoid bug with float value //zoomValue = tmpInt / 10 if (zoomValue < 0.0) { zoomValue = Math.abs(zoomValue); bFitToWindow = true; } else { bFitToWindow = false; if (zoomValue < 0.25) zoomValue = 0.25; } var item2 = toolbarButtons.rows[0].cells[ nZoomCombo ].childNodes[0]; if (typeof(item2) == 'object' && typeof(item2.setAttribute) != 'undefined') { if (bFitToWindow == false) item2.setAttribute('value', zoomValue) else item2.setAttribute('value', 0) } var obj = parent.hcMain.PageGroup // var bg = parent.hcMain.document.body.childNodes[0]; if (typeof(obj) == "object") { obj.style.visibility = 'hidden'; obj.style.zoom = zoomValue; // if( typeof( bg ) == "object" && zoomValue > 0.75 ) // bg.style.zoom = zoomValue; obj.style.visibility = 'visible'; } tryCenterPage() UpdateHitTestRectsByZoom() updateOverviewWindow() } function switchScrolling(b) { var obj = parent.hcMain.document.body if(b) obj.setAttribute("scroll","auto"); else obj.setAttribute("scroll","no"); } function ZoomToFit() { var obj = parent.hcMain.document.body; //parent.hcMain.frameElement if( !obj ) return; var wndHeight = parseInt(obj.clientHeight) var wndWidth = parseInt(obj.clientWidth) var oPage = parent.hcMain.PageGroup if (typeof(oPage) != "object") return switchScrolling(false) oPage.style.visibility = 'hidden'; var pageHeight = oPage.style.pixelHeight + 20 var pageWidth = oPage.style.pixelWidth + 20 var d = wndHeight / pageHeight if (pageWidth * d > wndWidth ) d = wndWidth / pageWidth if (getIEVersion() < 5.5) { tryCenterPage() updateOverviewWindow() } else { setZoom(-d) } oPage.style.visibility = 'visible'; } function DoZoomToFitInit() { ZoomToFit() }